package com.xidian.zhiancloud.controller.myyb;

import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.SysDepart;
import com.xidian.zhiancloud.service.myyb.IDepartService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 系统设置-组织层级
 *
 */
@RestController
@RequestMapping("/depart")
public class DepartController {

    private final static Logger logger = LoggerFactory.
            getLogger(DepartController.class);

    @Autowired
    private IDepartService departService;

    /**
     *  显示组织层级列表
     *
     * @return 返回ResultDTO对象
     */
    @GetMapping("/depart_list")
    public ResultDTO<List<SysDepart>> selectDepartList() {
        return ResultDTO.successOf(departService.selectDepartList(), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 编辑
     * @param depart 组织机构
     * @return 返回 ResultDTO 对象
     */
    @GetMapping("/updateDepart")
    public ResultDTO<Boolean> updateDepart(SysDepart depart) {
        departService.updateById(depart);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }


}
